/****************************************************************************

	COPYRIGHT(C) MAXSI SOFTWARE, JONAS 'SORTIE' TERMANSEN 2008, 2009, 2010

    This file is part of Maxsi Compile.

    Maxsi Compile is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Maxsi Compile is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public License
    along with Maxsi Compile.  If not, see <http://www.gnu.org/licenses/>.

	*/ #include "MaxsiCompileContributors.h" /*

	If you modify this file, please enter your name below and provide contact
	information in MaxsiCompileContributors.h. For more information please see
	MaxsiCompileContributors.h.
	
	Contributors to this file:

	- Jonas 'Sortie' Termansen
	- [your name here]


	MaxsiCompile.exe
	A system to control MaxsiCompile Systems.

	CompileMap.cpp
	Triggers the actual compiling

****************************************************************************/

#ifndef CompileMap_H
#define CompileMap_H

//=============================================================================
//	Forward declarations
//=============================================================================
class ModMeta;
class MapMeta;
class Configuration;
class ToolConfiguration;
class CompileRequest;

//=============================================================================
//	ModMeta: A meta class for a mod with all the paths needed
//=============================================================================
class ModMeta
{
public:
	ModMeta();
	~ModMeta();

public:
	MESTR*		GameDir;
	MESTR*		GameExe;
	MESTR*		BSP;
	MESTR*		Vis;
	MESTR*		Light;
	MESTR*		GameExeDir;
	MESTR*		MapDir;
	MESTR*		BSPDir;

public:
	MESTR*		SDKEngineVersion;
	MESTR*		SDKEngineRoot;

};

//=============================================================================
//	MapMeta: A meta class for a map with all the paths needed
//=============================================================================
class MapMeta
{
public:
	MapMeta();
	~MapMeta();

public:
	MESTR*		MapName;
	MESTR*		FileName;

public:
	ModMeta*	Mod;

};

//=============================================================================
//	Configuration: A list of all the tools and their state needed for a compile
//=============================================================================
class Configuration
{
public:
	Configuration();
	~Configuration();

public:
	size_t					NumConfigurations;
	ToolConfiguration**		Configurations;

};

//=============================================================================
//	ToolConfiguration: A class holding all the variables used by a tool
//=============================================================================
class ToolConfiguration
{
public:
	ToolConfiguration();
	~ToolConfiguration();

public:
	MESTR*		Executable;
	MESTR*		AdditionalArguments;
	MESTR*		WorkingDir;

public:
	MESTR*		CreateCommandLine(MapMeta* Input);
	MESTR*		GetWorkingDir(MapMeta* Input);

};

//=============================================================================
//	CompileRequest: Contains all the commands used to compile a specific map
//=============================================================================
class CompileRequest
{
public:
	CompileRequest();
	~CompileRequest();

public:
	MapMeta*	Map;

public:
	size_t		NumCommands;
	MESTR**		Commands;
	MESTR**		WorkingDirs;
	
};

//=============================================================================
//	Functions that compile stuff
//=============================================================================
CompileRequest*		CreateCompileRequest(MapMeta* Map, Configuration* Config);

int					CompileMap(CompileRequest* Request);
int					CompileMap(MESTR* MapName, MESTR* VBSPParam, MESTR* VVISParam, MESTR* VRadPass1Param, MESTR* VRadPass2Param);

//=============================================================================
//	Shared data table
//=============================================================================
extern	MESTR*	SteamDir;
extern	MESTR*	SteamUsername;
extern	MESTR*	SDKEngineVersion;
extern	MESTR*	ModGameFolder;
extern	MESTR*	SDKGameFolder;
extern	MESTR*	ModMapSrcFolder;
extern	MESTR*	ModMapsFolder;

#endif